# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=mimedefang
pkgver=3.4.1
pkgrel=0
pkgdesc="e-mail filtering tool that works with the Sendmail Milter library"
url="https://mimedefang.org"
arch="all"
license="GPL-2.0-only"
pkgusers="defang"
pkggroups="defang"
depends="
	perl-digest-sha1
	perl-html-parser
	perl-io-socket-ssl
	perl-mail-dkim
	perl-mail-spf
	perl-mime-base64
	perl-mime-tools
	perl-net-dns
	perl-unix-syslog
	tzdata
	"
# if compiled with support from clamd it must be run as user defang
makedepends="clamav-clamdscan clamav-scanner libmilter-dev"
case "$CARCH" in
	x86) :
		;;
	*) makedepends="$makedepends rspamd-client"
		;;
esac
checkdepends="perl-archive-zip perl-test-class perl-test-harness-utils perl-test-most"
subpackages="$pkgname-doc"
install="$pkgname.pre-install"
source="https://github.com/The-McGrail-Foundation/MIMEDefang/releases/download/v$pkgver/mimedefang-$pkgver.tar.gz
	date-test.patch
	"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-user=defang
	make
}

check() {
	make test SMTP_TEST=no
}

package() {
	make DESTDIR="$pkgdir" install
	install -dm 750 -o defang -g defang "$pkgdir"/var/log/$pkgname
}

sha512sums="
2734834774c44d53a4e5632d113385e13e4e2ae8e94d5a766dca4f5a08b974373dbd6ee8a815a5b12d967b485154344ddbc9b70eb5ffe4988f061523e60ac0ab  mimedefang-3.4.1.tar.gz
3921058b9526dfbb2480d989e45ec9e1fc584470afb024f328e682b0fccdd8121945f9b61794c3abb599b22b0a0797dfaeb3071930e8f339cf0508baf1513ecd  date-test.patch
"
